package com.hdax.dmw.item.mapstruct;

import com.hdax.dmw.entity.item.ItemType;
import com.hdax.dmw.item.dtos.HotItemsDto;
import com.hdax.dmw.item.dtos.IndexNavDto;
import com.hdax.dmw.item.service.ItemService;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Mapper(componentModel = "spring")
public abstract class NavDtoMapper {


    @Mappings({
            @Mapping(target = "hotItems",expression = "java(hotItems(s.getId()))")
    })
    public abstract IndexNavDto toTarget(ItemType s );
    public abstract List<IndexNavDto> toTargetList(List<ItemType> s );

    @Autowired
    private ItemService itemService;

    public List<HotItemsDto> hotItems(Long id){
        return itemService.hotItems(id);
    }

}
